<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.cqggrw.util.*"%>
<%@ page import="com.cqggrw.domain.*"%>
<%@ page import="com.cqggrw.service.*"%>
<%@ page import="com.cqggrw.service.impl.*"%>
<%
	request.setCharacterEncoding("utf-8");
	response.setContentType("text/html;charset=UTF-8");
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
	
	AdServiceI adService = new AdServiceImpl();
	List<Ad> adList = adService.get();
	Map<Integer, Ad> adMap = new HashMap<Integer, Ad>();
	for(Ad ad : adList) {
		adMap.put(ad.getId(), ad);
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>公共人物网</title>
<link href="css/columns.css" rel="stylesheet" type="text/css" />
<link href="css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../jslib/jquery-1.8.0.min.js">
	
</script>
<script type="text/javascript" src="Script/jcarousellite.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("#thumbs").jCarouselLite({
			btnPrev : "#prev",
			btnNext : "#next",
			auto : 2000,//图片停留时间
			scroll : 1,//每次滚动覆盖的图片个数
			speed : 3000, //设置速度，0是不动。其次就是数字越大 ，移动越慢。
			vertical : false,//横向（true），竖向（false）
			visible : 4, //显示的数量
			circular : false
		//是否循环
		});
		$("#Hidden1").val($("#Hidden1").attr("newid"));
	});

	var n = 1;
	function change() {
		if (n < 5) {
			$("#" + n + "").click();
			n++;
		} else
			n = 1;
	}
	function init() {
		change();
		setInterval(change, 5000);
	}

	function clickmessage() {
		var text = $(".input").val();
		if (text != "") {
			if (text.length > 150) {
				alert("留言失败,留言内容过长！");
				return false;
			} else {
				saveMessage($('#contentID').val(), text);
			}
		} else {
			alert("留言失败,留言内容不能为空！");
			return false;
		}
	}

	function saveMessage(id, message) {
		$.ajax({
			url : '${pageContext.request.contextPath}/appraiseAction!add.action',
			type : 'POST',
			dataType : 'json',
			data : {
				newsId : id,
				message : message
			},
			success : function(result) {
				if (result) {
					if (result.success) {
						$(".input").val('');
					}
					alert(result.msg);
				}
			}
		});
	}
</script>
<style type="text/css">
#prev {
	width: 16px;
	height: 61px;
	float: left;
	margin-top: 20px;
	position: absolute;
	z-index: 1px;
	margin-top: -90px;
}

#next {
	width: 16px;
	height: 61px;
	float: right;
	margin-top: 30px;
	margin-top: -90px;
	margin-right: 30px;
}
</style>
</head>
<body onload="init()" onresize="location.reload();">
	<div class="top">
		<a target="_blank" href="<%=basePath%>">公共人物首页</a> - <a target="_blank" href="../news.jsp?id=13"><font color="#FF0000">焦点</font> </a> - <a target="_blank" href="../news.jsp?id=2">关注</a> - <a target="_blank" href="../news.jsp?id=4">达人</a> - <a target="_blank" href="../news.jsp?id=14">教育</a> - <a target="_blank" href="../news.jsp?id=3">精英领导</a> - <a target="_blank" href="../news.jsp?id=28">区县</a> - <a target="_blank" href="../news.jsp?id=26">观点</a> - <a target="_blank" href="../news.jsp?id=12">公共</a> - <a target="_blank" href="../news.jsp?id=21">文萃</a> - <a target="_blank" href="../news.jsp?id=6">追寻</a> - <a target="_blank" href="../news.jsp?id=10">访谈</a> - <a target="_blank" href="../news.jsp?id=23">环球</a> - <a target="_blank" href="../news.jsp?id=25">体育</a>- <a target="_blank" href="../news.jsp?id=29">图说天下</a>
	</div>
	<hr />
	<div class="content">
		<div class="content_left">
			<div class="banner">
				<a target="_blank" href="<%=adMap.get(16).getLink()%>"><img border="0" src="../images/AdImg/<%=adMap.get(16).getImgName()%>" /> </a>
			</div>
			<%
				String id = request.getParameter("id");
								NewsServiceI<News> service = new NewsServiceImpl();
								News news = new News();
								news.setId(Integer.parseInt(id));
								news = service.get(news);
								int typeId = news.getType();
			%>
			<div class="guild">
				<div class="guild1">
					<img src="../images/new1/news1_11.gif" width="59" height="15" />--> <a id="HyperLink1" href="../news.jsp?id=<%=news.getType()%>"><%=news.getTypeName()%></a> --> <span id="Label1" title="<%=news.getName()%>"><%=news.getName().length()<=15?news.getName():news.getName().substring(0, 15)%></span>
				</div>
				<div class="search"></div>
			</div>
			<div class="news">
				<p class="news_title"><%=news.getName()%></p>
				<p class="news_time"><%=news.getAddDate()%>
					来源：<%=news.getComfrom()%></p>
				<p class="summary" style='display:<%=news.getTxtContent().length()<3?"none":"true"%>'><%=news.getTxtContent()%></p>
				<a target="_blank" href="#" class="a6">新闻中心</a>
				<%
					List<Img> imgList = new ArrayList<Img>();
							if (true) {
						        		Connection conn = null;
						        		PreparedStatement ps = null;
						        		ResultSet rs = null;
						        		Img img = null;
						        	
						        		String sql = "select * from tbl_img where falg = ?;";
						        		try {
						        			conn = DBUtil.getConn();
						        			ps = conn.prepareStatement(sql);
						        			ps.setString(1, news.getFalg());
						        			rs = ps.executeQuery();
						        			while(rs.next()) {
						        				img = new Img();
						        				img.setName(rs.getString("name"));
						        				img.setDes(rs.getString("des"));
						        				imgList.add(img);
						        			}
						        		} catch (Exception e) {
						        			e.printStackTrace();
						        		} finally {
						        			DBUtil.close(conn, ps, rs);
						        		}
						        	}
				%>
				<div class="news_img"
					style="display:<%=imgList.size() < 2?"none":"true"%>;">
					<div id="panel" style="overflow:hidden; text-align:center;">
						<%
							if(imgList.size()>1) {
						%>
						<img id="largeImage"
							src='../images/img/<%=imgList.get(0).getName()%>'
							alt="<%=imgList.get(0).getDes()%>" />
						<%
							}
						%>
					</div>
					<div id="thumbs">
						<ul>
							<%
								for(Img img : imgList){
							%>
							<li><img name="imgName" src='../images/img/<%=img.getName()%>' id='1'
								width="100" height="98" alt='<%=img.getDes()%>' />
							</li>
							<%
								}
							%>
						</ul>
					</div>
					<span id="prev"><img src="../images/new1/news1_29.gif"
						id="1" alt="1st image description" width="19px" height="61px" />
					</span> <span id="next"><img src="../images/new1/news1_32.gif"
						id="5" alt="5th image description" width="19px" height="61px" />
					</span>
					<script>
					var imgs = $('img[name=imgName]');
					for(var i = 0; i < imgs.length; i++) {
						var theImage = new Image();
						theImage.src = $(imgs[i]).attr("src");
						var nowImageWidth = Math.round(theImage.width/(theImage.height/100));
						$(imgs[i]).attr({
							width : nowImageWidth,
							heigth : 100
						});
					}
                $('#thumbs').delegate('img','click', function(){
	                $('#largeImage').attr('src',$(this).attr('src'));
                });
            </script>
				</div>
				<div class="news_cont" style="overflow:hidden;">
					<%=news.getContent()%>
					<p class="news_info">
						（本文来源：<%=news.getComfrom()%>
						）
					</p>
				</div>
				<div class="view">
					<p class="view_title">您对该文章有什么看法？</p>
					<input type="hidden" id="contentID" value="<%=id%>" />
					<textarea name="aa" id="aa" class="input" maxlength="150" cols="50" rows="3"></textarea>
					<div class="input1">
						<input name="Text2" type="text" id="Text2" style="display:none;" value="2724" />
						<div class="input2">
							最多输入：<font color="#FF0000">150</font>字
						</div>
						<input type="image" src="../images/new1/news1_48.gif" name="" value="" onclick="clickmessage()" />
					</div>
				</div>
				<div class="related">
					<div class="related_title">相关文章</div>
					<ul>
						<%
							List<News> newsListForId = service.getByTypeId(typeId);
							for (int i = 0; i < 8 && i < newsListForId.size(); i++) {
						%>
						<li><a target="_blank" href='news.jsp?id=<%=newsListForId.get(i).getId()%>'><span id="rptxiangguanwenzhang_ctl00_lbljiaodiantop" title="<%=newsListForId.get(i).getName()%>"><%=newsListForId.get(i).getName().length() <= 30 ? newsListForId.get(i).getName() : newsListForId.get(i).getName().substring(0, 30)%></span> </a> <%=newsListForId.get(i).getAddDate()%></li>
						<%
							}
						%>
					</ul>
				</div>
			</div>
		</div>
		<div class="content_right">
			<div class="nomber1">
				<div class="nomber1_title">头条推荐</div>
				<ul>
					<%
						if (true) {
							Connection conn = null;
							PreparedStatement ps = null;
							ResultSet rs = null;

							String sql = "select a.*, b.name typeName from tbl_news a, tbl_category b where a.type = b.id order by ckbtop desc limit 10;";
							int i = 1;
							try {
								conn = DBUtil.getConn();
								ps = conn.prepareStatement(sql);
								rs = ps.executeQuery();
								while (rs.next()) {
					%>
					<li>【<%=rs.getString("typeName")%>】<a target="_blank" href='news.jsp?id=<%=rs.getInt("id")%>'><span id="rpttoutiaotuijian_ctl00_lbljiaodiantop" title="<%=rs.getString("name")%>"><%=rs.getString("name").length() <= 10 ? rs.getString("name") : rs.getString("name").substring(0, 10)%></span> </a>
					</li>
					<%
						i++;
								}
							} catch (Exception e) {
								e.printStackTrace();
							} finally {
								DBUtil.close(conn, ps, rs);
							}
						}
					%>
				</ul>
			</div>
			<div class="banner1">
				<a target="_blank" href="<%=adMap.get(17).getLink()%>"><img border="0" src="../images/AdImg/<%=adMap.get(17).getImgName()%>" /> </a>
			</div>
			<div class="nomber1">
				<div class="nomber1_title">热点推荐</div>
				<ul>
					<%
						if (true) {
							Connection conn = null;
							PreparedStatement ps = null;
							ResultSet rs = null;

							String sql = "select a.*, b.name typeName from tbl_news a, tbl_category b where a.type = b.id order by cknishot desc limit 10;";
							int i = 1;
							try {
								conn = DBUtil.getConn();
								ps = conn.prepareStatement(sql);
								rs = ps.executeQuery();
								while (rs.next()) {
					%>
					<li>【<%=rs.getString("typeName")%>】<a target="_blank" href='news.jsp?id=<%=rs.getInt("id")%>'><span id="rpttoutiaotuijian_ctl00_lbljiaodiantop" title="<%=rs.getString("name")%>"><%=rs.getString("name").length() <= 10 ? rs.getString("name") : rs.getString("name").substring(0, 10)%></span> </a>
					</li>
					<%
						i++;
								}
							} catch (Exception e) {
								e.printStackTrace();
							} finally {
								DBUtil.close(conn, ps, rs);
							}
						}
					%>
				</ul>
			</div>
			<div class="banner1">
				<a target="_blank" href="<%=adMap.get(18).getLink()%>"><img border="0" src="../images/AdImg/<%=adMap.get(18).getImgName()%>" /> </a>
			</div>
			<div class="sports">
				<div class="nomber1_title">体育推荐</div>
				<%
					if (true) {
						Connection conn = null;
						PreparedStatement ps = null;
						ResultSet rs = null;

						String sql = "select a.*, b.name typeName from tbl_news a, tbl_category b where b.id = 25 and a.type = b.id order by ckbtop desc limit 3;";
						int i = 0;
						try {
							conn = DBUtil.getConn();
							ps = conn.prepareStatement(sql);
							rs = ps.executeQuery();
							while (rs.next() && i < 2) {
				%>
				<ul class="sports1">
					<li class="sports_img"><a target="_blank" href='news.jsp?id=<%=rs.getInt("id")%>'> <img src='../images/img/<%=rs.getString("filename")%>' width="120" height="90" alt="" style='border:0px;' /> </a></li>
					<li><a target="_blank" href='news.jsp?id=<%=rs.getInt("id")%>'><%=rs.getString("name")%></a></li>
				</ul>
				<%
					i++;
							}
						} catch (Exception e) {
							e.printStackTrace();
						} finally {
							DBUtil.close(conn, ps, rs);
						}
					}
				%>
			</div>
			<div class="gossip">
				<div class="gossip_title">
					<span>娱乐八卦</span> <a target="_blank" href="#">more</a>
				</div>
				<%
					if (true) {
						Connection conn = null;
						PreparedStatement ps = null;
						ResultSet rs = null;

						String sql = "select a.*, b.name typeName from tbl_news a, tbl_category b where b.id = 2 and a.type = b.id order by ckbtop desc limit 4;";
						int i = 0;
						try {
							conn = DBUtil.getConn();
							ps = conn.prepareStatement(sql);
							rs = ps.executeQuery();
							while (rs.next() && i < 3) {
								if (i == 0) {
				%>
				<div class="gossip_cont">
					<h3>
						<a target="_blank" href='news.jsp?id=<%=rs.getInt("id")%>'><span id="rptyulebagua_ctl00_lbljiaodiantop" title="<%=rs.getString("name")%>"><%=rs.getString("name").length() <= 16 ? rs.getString("name") : rs.getString("name").substring(0, 16)%></span> </a>
					</h3>
					<%=rs.getString("txtContent").length() <= 40 ? rs.getString("txtContent") : rs.getString("txtContent").substring(0, 40)%>...
				</div>
				<%
					} else {
				%>
				<div class="gossip_cont">
					<h3>
						<a target="_blank" href='news.jsp?id=<%=rs.getInt("id")%>'><span id="rptyulebagua_ctl01_lbljiaodiantop" title="<%=rs.getString("name")%>"><%=rs.getString("name").length() <= 16 ? rs.getString("name") : rs.getString("name").substring(0, 16)%></span> </a>
					</h3>
					...
				</div>
				<%
					}
								i++;
							}
						} catch (Exception e) {
							e.printStackTrace();
						} finally {
							DBUtil.close(conn, ps, rs);
						}
					}
				%>
			</div>
			<div class="banner1">
				<a target="_blank" href="<%=adMap.get(19).getLink()%>"><img border="0" src="../images/AdImg/<%=adMap.get(19).getImgName()%>" /> </a>
			</div>
			<div class="service">
				<h3>
					<span>公共服务</span>
				</h3>
				<ul>
					<%
						List<News> newsList12 = service.getByTypeId(12);
						for (int i = 0; i < 10 && i < newsList12.size(); i++) {
					%>
					<li><a target="_blank" href='news.jsp?id=<%=newsList12.get(i).getId()%>'> <span id="rptgonggongfuwu_ctl00_lbljiaodiantop" title="<%=newsList12.get(i).getName()%>"><%=newsList12.get(i).getName().length() <= 14 ? newsList12.get(i).getName() : newsList12.get(i).getName().substring(0, 14)%></span> </a> <%
 	}
 %>
					
				</ul>
			</div>
			<div class="banner1">
				<a target="_blank" href="<%=adMap.get(20).getLink()%>"><img border="0" src="../images/AdImg/<%=adMap.get(20).getImgName()%>" /> </a>
			</div>
		</div>
	</div>
	<div class="clear"></div>
	<div class="foot">
		<div class="links">
			<span>友情链接：</span>
			<%
				LinkServiceI linkService = new LinkServiceImpl();
				List<Link> links = (ArrayList<Link>) linkService.get();
				for (int i = 0; i < links.size(); i++) {
			%>
			<a target="_blank" href='<%=links.get(i).getUrl()%>'><%=links.get(i).getName()%></a>
			<%
				if (i < links.size() - 1)
						out.print("|");
				}
			%>
		</div>
		<div class="copyright">
			<div class="company">主办单位：重庆行政公共人物杂志社</div>
			<div class="map">
				<a href="about.jsp?id=1">关于我们</a> | <a href="about.jsp?id=2">杂志简介</a> | <a href="about.jsp?id=3">广告刊例</a> | <a href="about.jsp?id=4">组织机构</a> | <a href="about.jsp?id=5">联系我们</a> | <a href="about.jsp?id=6">本网声明</a> | <a href="about.jsp?id=7">版权声明</a>
			</div>
			<p>
				Copyright &copy; 2008-2012 www.cqggrw.com All Rights Reserved 渝ICP备12001034号-1&nbsp;技术支持：<a href="http://www.cqgew.com">重庆政企</a>
		</div>
	</div>
</body>
</html>